//
//  SettingDetailController.m
//  Doc Bao
//
//  Created by Vinh Huynh on 9/30/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SettingDetailController.h"
#import "News.h"
#import "NewsExtensions.h"
#import "NewsView.h"
#import "ListEditController.h"

@implementation SettingDetailController
@synthesize scrollView;
@synthesize mainSettingView;
@synthesize newsArray;
//@synthesize newsView;
//@synthesize newsLogo; 
//@synthesize newsName;
 
/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

-(IBAction) editListButton{
	ListEditController *controller = [[ListEditController alloc] init];
	[self.navigationController pushViewController:controller animated:YES];
	[controller release];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	newsArray = [[NSMutableArray alloc] initWithArray:[News getNews]];
	[scrollView setContentSize:CGSizeMake(320, 1250)];
	[scrollView addSubview:mainSettingView];
	[mainSettingView setFrame:CGRectMake(0, 0, 320, 200)];
	CGFloat y = 200.00;
	
	for (int i = 0; i< [newsArray count]; i++) {
		NewsView *newsView = [[[NSBundle mainBundle] loadNibNamed:@"NewsView" owner:self options:nil] lastObject];
		News *news = [newsArray objectAtIndex:i];
		[scrollView addSubview:newsView];
		[newsView setFrame:CGRectMake(0, y, 320, 150)];
		newsView.newsName.text = news.Name;
		newsView.newsLogo.image = [UIImage imageNamed:news.Logo];
		y = y + 150;
	}
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {    
	self.scrollView = nil;
	self.mainSettingView = nil;
	//self.newsView = nil;
	//self.newsName =nil;
	//self.newsLogo = nil;
	[newsArray release];
	[super dealloc];
}


@end
